package com.yzy.fly.type;

import lombok.Getter;
import lombok.Setter;

public enum ViewWidgetType {
    //    STRING,DOUBLE,FLOAT,BOOLEAN,BIGDECIMAL,INT
    GRID("grid", "","栅格"),
    TABLE("table", "","表格"),
    TAB("tab", "" ,"标签页"),//String.class.getName()
    CARD("card", "" ,"卡片"),
    INPUT("input", "I","单行输入"),
    TEXTAREA("textarea", "I","多行输入"),
    NUMBER("number", "I","计数器"),
    RADIO("radio", "I","单选项"),
    CHECKBOX("checkbox", "I","多选项"),
    SELECT("select", "I","下拉选项"),
    TIME("time", "I","时间"),
    TIME_RANGE("time-range", "I","时间范围"),
    DATE("date", "I","日期"),
    DATE_RANGE("date-range", "I","日期范围"),
    SWITCH("switch", "I","开关"),
    RATE("rate", "I","评分"),
    TABLE_CELL("table-cell", "I","单元格"),
    HTML_TEXT("html-text", "I","HTML"),
    BUTTON("button", "i","按钮"),
    DIVIDER("divider", "i","分割线"),
    PICTURE_UPLOAD("picture-upload", "i","图片上传"),
    FILE_UPLOAD("file-upload", "i","文件上传"),
    RICH_EDITOR("rich-editor", "i","富文本"),
    CASCADER("cascader", "i","级联选择"),
    ALERT("alert", "i","提示");
//    private static String INT = "Ljava/lang/Int;";
//    private static String INTEGER = "Ljava/lang/Integer;";
//    private static String LONG = "Ljava/lang/Long;";
//    private static String STRING = "Ljava/lang/String;";
    @Setter
    @Getter
    private String type;
    @Setter
    @Getter
    private String value;
    @Setter
    @Getter
    private String desc;

    ViewWidgetType(String type, String value, String desc) {
        this.type = type;
        this.value = value;
        this.desc = desc;
    }

    public static ViewWidgetType type(String type) {
//        if (StringUtils.isBlank(type)) {
//            return ViewWidgetType.STRING;
//        }
        ViewWidgetType fieldType = null;
        ViewWidgetType[] values = ViewWidgetType.values();
        try {
            for (int i = 0; i < values.length; i++) {
                ViewWidgetType value = values[i];
                if (value.getType().equals(type)) {
                    fieldType = value;
                    break;
                }
            }
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            fieldType = null;
        }
        return fieldType;
    }


}
